package com.vn.toaa.karaoke.ui;

import java.util.ArrayList;
import java.util.List;

import com.vn.toaa.karaoke.database.SongModel;

public class ValueContainer {
	
	private static ValueContainer sInstance = null;
	
	public static ValueContainer getInstance() {
		if (sInstance == null) {
			sInstance = new ValueContainer();
		}
		return sInstance;
	}
	
	private List<SongModel> mSongModelsInFive;
	private List<SongModel> mSongModelsInSix;
	private List<SongModel> mSongModelsInFavorite;
	
	public List<SongModel> searchByKeywordInFive(String keyword) {
		List<SongModel> result = new ArrayList<SongModel>();
		if (mSongModelsInFive != null) {
			for (int i = mSongModelsInFive.size() - 1; i >= 0; i--) {
				final SongModel songModel = mSongModelsInFive.get(i);
				final String songId = String.valueOf(songModel.getSongId()).toLowerCase();
				final String songTitle = songModel.getTitle().toLowerCase();
				final String songTitleSearch = songModel.getTitleSearch().toLowerCase();
				final String songLyric = songModel.getLyric().toLowerCase();
				final String songLyricSearch = songModel.getLyricSearch().toLowerCase();
				final String songAuthor = songModel.getAuthor().toLowerCase();
				final String songAuthorSearch = songModel.getAuthorSearch().toLowerCase();
				if (songId.contains(keyword) || songTitle.contains(keyword) || songTitleSearch.contains(keyword)
						|| songLyric.contains(keyword) || songLyricSearch.contains(keyword)
						|| songAuthor.contains(keyword) || songAuthorSearch.contains(keyword)) {
					result.add(songModel);
				}
			}
		}
		return result;
	}
	
	public List<SongModel> searchByKeywordInSix(String keyword) {
		List<SongModel> result = new ArrayList<SongModel>();
		if (mSongModelsInSix != null) {
			for (int i = mSongModelsInSix.size() - 1; i >= 0; i--) {
				final SongModel songModel = mSongModelsInSix.get(i);
				final String songId = String.valueOf(songModel.getSongId()).toLowerCase();
				final String songTitle = songModel.getTitle().toLowerCase();
				final String songTitleSearch = songModel.getTitleSearch().toLowerCase();
				final String songLyric = songModel.getLyric().toLowerCase();
				final String songLyricSearch = songModel.getLyricSearch().toLowerCase();
				final String songAuthor = songModel.getAuthor().toLowerCase();
				final String songAuthorSearch = songModel.getAuthorSearch().toLowerCase();
				if (songId.contains(keyword) || songTitle.contains(keyword) || songTitleSearch.contains(keyword)
						|| songLyric.contains(keyword) || songLyricSearch.contains(keyword)
						|| songAuthor.contains(keyword) || songAuthorSearch.contains(keyword)) {
					result.add(songModel);
				}
			}
		}
		return result;
	}
	
	public List<SongModel> getSongModelsInFive() {
		return mSongModelsInFive;
	}

	public void setSongModelsInFive(List<SongModel> songModels) {
		this.mSongModelsInFive = songModels;
	}

	public List<SongModel> getSongModelsInSix() {
		return mSongModelsInSix;
	}

	public void setSongModelsInSix(List<SongModel> songModelsInSix) {
		this.mSongModelsInSix = songModelsInSix;
	}

	public List<SongModel> getSongModelsInFavorite() {
		return mSongModelsInFavorite;
	}

	public void setSongModelsInFavorite(List<SongModel> songModelsInFavorite) {
		this.mSongModelsInFavorite = songModelsInFavorite;
	}

}
